package com.example.gmallsugar.mapper;

import com.example.gmallsugar.bean.Kw;
import com.example.gmallsugar.bean.Traffic;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author lzc
 * @Date 2023/5/6 14:06
 */
public interface TrafficMapper {
    /*@Select("SELECT\n" +
        "    toHour(stt) AS hour,\n" +
        "    sum(pv_ct) AS pv,\n" +
        "    sum(uv_ct) AS uv,\n" +
        "    sum(sv_ct) AS sv\n" +
        "FROM dws_traffic_vc_ch_ar_is_new_page_view_window\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n" +
        "GROUP BY toHour(stt)")
    List<Traffic> traffic(Integer date);*/
    
    @Select("SELECT\n" +
        "    hour(stt) AS hour,\n" +
        "    sum(pv_ct) AS pv,\n" +
        "    sum(uv_ct) AS uv,\n" +
        "    sum(sv_ct) AS sv\n" +
        "FROM dws_traffic_vc_ch_ar_is_new_page_view_window\n" +
        "partition(par#{date})" +
        "GROUP BY hour(stt)")
    List<Traffic> traffic(Integer date);
    
    @Select("SELECT\n" +
        "    keyword,\n" +
        "    sum(keyword_count) as keyword_count\n" +
        "FROM dws_traffic_keyword_page_view_window\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n" +
        "GROUP BY keyword")
    List<Kw> kw(Integer date);
    
    public static void main(String[] args) {
        System.out.println("SELECT\n" +
                               "    hour(stt) AS hour,\n" +
                               "    sum(pv_ct) AS pv,\n" +
                               "    sum(uv_ct) AS uv,\n" +
                               "    sum(sv_ct) AS sv\n" +
                               "FROM dws_traffic_vc_ch_ar_is_new_page_view_window\n" +
                               "partition(par#{date})" +
                               "GROUP BY hour(stt)");
    }
}
